#ifndef DEV_PARAM_FILE_H
#define DEV_PARAM_FILE_H

#include <QtCore>

class CDevParamField;

//统一处理ini/BA10Temp.ini文件的读取和写入
class CDevParamFile
{
public:
    CDevParamFile();
    ~CDevParamFile();

    CDevParamFile(const CDevParamFile& that);
    CDevParamFile& operator=(const CDevParamFile& that);

    void CopyFrom(const CDevParamFile* pthat);

    void Clear();

    bool operator==(const CDevParamFile& that);
    bool operator!=(const CDevParamFile& that);


public:
    int GetReadPageCount();
    QString GetReadPageName(int iReadType);
    int GetReadPageDataCount(int iindex);
    int GetWritePageCount();
    QString GetWritePageName(int iWriteType);
    int GetWritePageDataCount(int iindex);
    bool HasReadPage();
    bool HasWritePage();
    bool HasReadWritePage();

    int GetIntCount();
    int GetFloatCount();

    void AddIntField(const QString& strKey, const QString& strShowName, const QString& strDefaultName = "", const QString& strDefaultValue = "");
    void AddFloatField(const QString& strKey, const QString& strShowName, const QString& strDefaultName = "", const QString& strDefaultValue = "");

    bool ExistField(const QString& strKey);
    CDevParamField* CheckField(const QString& strKey);
    CDevParamField* GetFieldByKey(const QString& strKey);
    CDevParamField* GetField(int iDataType, int iFieldIndex);
    void ReadAcFields(int iDevIndex); //读空调的配置
    void ReadLcFields(int iDevIndex); //读液冷的配置
    void ReadDryFields(int iDevIndex); //读除湿的配置
    void ReadEnvCtrlFields(int iDevIndex); //读环控的配置
    void ReadFireFields(int iDevIndex); //读消防的配置
    void ReadWaterFields(int iDevIndex); //读水浸的配置
    void ReadPcsFields(int iDevIndex); //读PCS逆变器的配置
    void ReadMeterFields(int iDevIndex); //读电表的配置
    void ReadThFields(int iDevIndex); //读温湿度的配置
    void ReadEgFields(int iDevIndex); //读门禁的配置
    void ReadDcdcFields(int iDevIndex); //读Dcdc的配置
    void ReadCpFields(int iDevIndex); //读充电桩的配置
    void ReadGasFields(int iDevIndex); //读可燃气体的配置
    void ReadIoFields(int iDevIndex); //读输入输出的配置
    void ReadUpsFields(int iDevIndex); //读UPS的配置
    QMap<int, QString> GetMapValues(const QString& strKey);
    QList<QPair<int, QString> > GetListValues(const QString& strKey);
    QString GetIntText(const QString& strKey, int ivalue);
    int GetFieldCount(int iDataType);
    QList<CDevParamField*> GetFieldList(int iDataType);

private:
    //验证变量的值范围(小于最小值则取最小值，大于最大值则取最大值)
    void CheckIntRange(int& iValue, int iMinValue, int iMaxValue);

private:
    QStringList                     m_listReadPages;
    QList<int>                      m_listReadDataCount;
    QStringList                     m_listWritePages;
    QList<int>                      m_listWriteDataCount;
    int                             m_iIntCount;
    int                             m_iFloatCount;
    QMap<QString, CDevParamField*>  m_mapFields;
};
#endif //DEV_PARAM_FILE_H
